<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class GoodsPostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'pic' => 'image:jpeg',
            'goodsname' => 'required | max:32',
            'price' => 'required | numeric',
            'goodscolor' => 'required | max:10',
            'goodssize' => 'required',
            'goodsinfo' => 'max:100',
            'count' => 'required | integer',
        ];
    }

    //提示信息设定
    public function messages()
    {
        return [
            'pic.image' => '上传商品图片格式必须是:jpeg、png、bmp、gif、 或 svg',
            'goodsname.required' => '商品名不能为空',
            'goodsname.max' => '分类名不能大于32个字符',
            'price.required' => '商品价格不能为空',
            'price.between' => '输入价格不符合规格',
            'price.numeric' => '数据价格只能是整数',
            'goodscolor.required' => '请输入正确的商品颜色',
            'goodssize.required' => '请输入正确的商品大小',
            'goodsinfo.max' => '商品信息不能大于100个字符',
            'count.required' => '商品库存不能为能为空，',
            'count.integer' => '商品库存只能是整数',
        ];
    }
}
